<script type="text/html" data-template-name="random">
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
        <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name" style="width:70%;">
    </div>
    <div class="form-row">
        <label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
        <input type="text" id="node-input-property" style="width:70%;"/>
    </div>
    <div class="form-row">
        <label for="node-input-inte"><i class="fa fa-random"></i> <span data-i18n="random.label.generate"></label>
        <select type="text" id="node-input-inte" style="width:70%;">
            <option value="true" data-i18n="random.label.wholeNumber"></option>
            <option value="false" data-i18n="random.label.realNumber"></option>
        </select>
    </div>
    <div class="form-row">
        <label for="node-input-low"><i class="fa fa-arrow-down"></i> <span data-i18n="random.label.from"></label>
        <input type="text" id="node-input-low" data-i18n="[placeholder]random.label.lowestNumber" style="width:70%;">
    </div>
    <div class="form-row">
        <label for="node-input-high"><i class="fa fa-arrow-up"></i> <span data-i18n="random.label.to"></label>
        <input type="text" id="node-input-high" data-i18n="[placeholder]random.label.highestNumber" style="width:70%;">
    </div>
</script>

<script type="text/javascript">
    RED.nodes.registerType('random',{
        category: 'function',
        color:"#E2D96E",
        defaults: {
            name: {value:""},
            low:  {value: 1,validate:function(v) { return  !isNaN(v) || v.length === 0;} },
            high: {value: 10,validate:function(v) { return  !isNaN(v) || v.length === 0;} },
            inte: {value:"true"},
            property: {value:"payload",required:true}
        },
        inputs:1,
        outputs:1,
        icon: "debug.png",
        label: function() {
            return this.name||"random";
        },
        labelStyle: function() {
            return this.name?"node_label_italic":"";
        },
        oneditprepare: function() {
            if (this.property === undefined) {
                $("#node-input-property").val("payload");
            }
            $("#node-input-property").typedInput({default:'msg',types:['msg']});
        }
    });
</script>
